//
//  InvitationBaoJiaViewModel.m
//  GLGW_Shoping
//
//  Created by yang on 2018/12/10.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "InvitationBaoJiaViewModel.h"
#import "InvitationBaoJiaTableViewCell.h"
#import "GoodsOrStoreNavView.h"
#import "InvitationTopView.h"
#import "OrderOperationView.h"
#import "GLGWPopTosView.h"

@interface InvitationBaoJiaViewModel ()<UITableViewDelegate,UITableViewDataSource>

@end

@implementation InvitationBaoJiaViewModel

-(instancetype)initWithViewToViewModel:(UITableView *)tableView theSuperView:(UIView *)superView{
    if (self = [super initWithViewToViewModel:tableView theSuperView:superView]) {
        tableView.y = tableView.y+kHeightProportion_In_iPhoneTriploid(44);
        tableView.height = tableView.height - kHeightProportion_In_iPhoneTriploid(44);
        tableView.delegate = self;
        tableView.dataSource = self;
        tableView.rowHeight = kHeightProportion_In_iPhoneTriploid(140);
        tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, kHeightProportion_In_iPhoneTriploid(10))];
        [superView addSubview:tableView];
        //
        InvitationTopView * topView = [[InvitationTopView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, kHeightProportion_In_iPhoneTriploid(44)) inSuperView:superView];
        topView.Block_TapAction = ^{
            if (self.delegate && [self.delegate respondsToSelector:@selector(showSearchView)]) {
                [self.delegate showSearchView];
            }
        };
        //
    }
    return self;
}

#pragma mark -- UITableViewDelegate,UITableViewDataSource
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 10;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    InvitationBaoJiaTableViewCell * cell = [InvitationBaoJiaTableViewCell cellWithTableView:tableView];
    cell.Block_InviateAction = ^{
        OrderOperationView * opeartionView = [[OrderOperationView alloc] initWithPopOrderOperation:@[@"取消",@"确认邀请"] theTitleStr:@"邀请商家" theTosStr:@"小张店铺\n联系电话：188 6460 6968"];
        [opeartionView show];
        opeartionView.Block_CaseAction = ^(NSInteger tag) {
            if (tag == 311) {
                GLGWPopTosView * p_View = [[GLGWPopTosView alloc] initWithPopView:PopViewType_Success];
                p_View.tosTitle = @"邀请成功!";
            }
        };
    };
    return cell;
}

@end
